<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@page import="com.lemurian.bankdata.lite.utils.GlobalFunction" %>

<script type="text/javascript">

	$(document).ready(function () {
		function showSuccess(str,delay){
			if(delay){
			    $('#alertMessage').removeClass('error')
			        .html(str).stop(true,true).fadeIn()
			        .delay(delay).fadeOut(); return false;
			}
		}

		$('#validation_demo').submit(function(e) {
    		var $form = $(this);
            var formData = $form.serializeArray();

			$.ajax({
                type: 'POST',
                dataType:'json',
                url: 'MenuAction_save.do',
                data: formData,
                success: function(data) {
                	var message = data.jsonMessage;
                    var type = data.jsonType;

                    console.log('MESSAGE : '+message);
                    console.log('TYPE    : '+type);

                    if(type == "Success") {
                 	   showSuccess(message);
                 	   window.location.href='MenuAction_list.do';
                    } else if (message.length > 0) {
                 	   console.log(message);
                 	   showError(message);
                    } else {
                 	   window.location.href='LoginAction_logout.do';
                    }
                }
            });
			
        });

	});
        
</script>

<div class="header"><span><span class="ico gray administrator"></span>Add Menu</span>
</div><!-- End header -->	
<div class="content" >
	<s:form name="formBody" id="validation_demo">
	    <s:hidden name="start"/>
	    <s:hidden name="count"/>
	    <s:hidden name="orderBy"/>
	    <s:hidden name="ascDesc"/>
	    <s:hidden name="previousPage"/>
	    <s:hidden name="actionMethod" value="%{actionMethod}"/>
	    <s:hidden name="id" value="%{@com.lemurian.bankdata.lite.utils.GlobalFunction@encodeParameter(id)}"/>
	    <s:token/>
	
		<!-- Third / Half column-->
		<div class="widgets">
		
		<div class="oneTwo">
			<div class="section ">
				<label><s:text name="label.name"/><small>Nama dari Menu</small></label>   
				<div> 
				    <s:textfield cssClass="validate[required] text-input large" name="menu.name"
	                            labelposition="left" maxlength="128" id="name" autocomplete="off"/>
				</div>
			</div>
		
			<div class="section ">
				<label><s:text name="label.parent"/><small>Induk dari Menu</small></label>   
				<div style="width: 74%!importand"> 
					<s:select cssClass="validate[required] large chzn-select" list="parents" listKey="%{@com.lemurian.bankdata.lite.utils.GlobalFunction@encodeParameter(id)}" listValue="name" name="parentId" headerKey="0" headerValue="Select below" disabled="%{readOnly}" tooltip="" value="%{@com.lemurian.bankdata.lite.utils.GlobalFunction@encodeParameter(parentId)}"/>
				</div>
			</div>
			
			<div class="section ">
				<label><s:text name="label.isView"/><!--<small style="text-align:justify">Tentukan apakah akan ditampilkan dalam navigasi atau hanya action biasa</small>--></label>  
				<div> 
				    <s:checkbox name="menu.show" cssClass="yes_no_checkbox" theme="simple"/>
				</div>
			</div>
		
			<div class="section last">
	            <div>
	            	<a href="MenuAction_list.do" class="uibutton special" style="width:120px" >kembali</a> 
	            	<s:submit action="%{actionMethod}" value="simpan" cssClass="uibutton confirm " cssStyle="width:120px"/> 
	           	</div>
	        </div>
		</div>
			
		<div class="oneTwo">
			
			<div class="section ">
				<label><s:text name="label.description"/><small>Deskripsi dari Menu</small></label>   
				<div> 
				    <s:textfield cssClass="validate[required] text-input large" name="menu.description"
	                            labelposition="left" maxlength="128" id="description" autocomplete="off"/>
				</div>
			</div>
			
			<div class="section ">
				<label><s:text name="label.url"/><small>URL dari Menu</small></label>   
				<div> 
				    <s:textfield name="menu.url" cssClass="text-input large"
	                            labelposition="left" maxlength="100" id="url" autocomplete="off"/>
				</div>
			</div>
		  
		  	<div class="section ">
				<label><s:text name="label.isParent"/><!--<small style="text-align:justify">Tentukan apakah action ini sebagai induk atau sebgai sub</small>--></label>   
				<div> 
				    <s:checkbox name="menu.showParent" cssClass="yes_no_checkbox" theme="simple"/>
				</div>
			</div>
		  
		</div>
		
		</div><!-- End Third / Half column-->
	
	</s:form>

   <!-- clear fix -->
<div class="clear"></div>

</div><!-- End content -->